<template>
  
</template>

<script>
// @ is an alias to /src
import until from "../../assets/javascript/until";
export default {
  name: "order",
  components: {},
  data() {
    return {
      list: [],
      form: {},
      until: until,
      time: new Date()
    };
  },
  mounted() {
    for(let i in 3){
        console.log(i)
      }
    this.getCanvas();
    this.init();
  },
  methods: {
    init() {
      // this.$api
      //   .post(this.$url.data.liveIncome, {
      //     start: 1,
      //     size: 20
      //   })
      //   .then(res => {
      //     if (res) {
      //       this.list = res;
      //     }
      //   })
      //   .catch(error => {
      //     this.error = true;
      //   });
    },
    getCanvas() {
      this.$api
        .post(this.$url.data.findFensData, {})
        .then(res => {
          if (res) {
            this.form = res;
            this.setCanvas(res.fenSLineChatList);
          }
        })
        .catch(error => {});
    },
    setCanvas(data) {
      // data = [
      //   { dateStr: "11-10", goldNum: 88 },
      //   { dateStr: "11-11", goldNum: 188 },
      //   { dateStr: "11-12", goldNum: 45 },
      //   { dateStr: "11-13", goldNum: 100 },
      //   { dateStr: "11-14", goldNum: 115 }
      // ];
      var myChart = this.$echarts.init(
        document.getElementById("fans"),
        "light"
      );
      let dateList = data.map(function(item) {
        return item.dateStr;
      });
      let maxNum = 0,
        fensNum = [];
      let valueList = data.map(function(item, index) {
        fensNum.push(item.fensNum);
        return item.fensNum;
      });
      maxNum = fensNum.sort()[fensNum.length - 1];
      // 绘制图表
      myChart.setOption({
        // Make gradient line here
        visualMap: [
          {
            show: false,
            type: "continuous",
            seriesIndex: 0,
            min: 0,
            max: maxNum
          }
        ],
        tooltip: {
          trigger: "axis"
        },
        xAxis: [
          {
            data: dateList
          }
        ],
        yAxis: [
          {
            splitLine: { show: false }
          }
        ],
        grid: [
          {
            bottom: "30%"
          }
        ],
        series: [
          {
            type: "line",
            showSymbol: false,
            data: valueList,
            axisLine: {
              // 坐标轴线
              lineStyle: {
                // 属性lineStyle控制线条样式
                color: [
                  [0.2, "#c23531"],
                  [0.8, "#63869e"],
                  [1, "#91c7ae"]
                ]
              }
            }
          }
        ]
      });
    }
  }
};
</script>

<style lang="scss" scoped>
@import "@/assets/css/variable.scss";
.boxs {
  padding: 0 15px;
  // padding: 10px 15px;
  .time {
    margin-top: 10px;
    padding: 10px 0 17px;
    color: #2e2e2e;
    span {
      font-size: 0.15rem;
      margin-right: 10px;
      font-weight: bold;
    }
    .update-time {
      color: #999;
      font-size: 0.12rem;
      font-weight: normal;
    }
  }
  .rows {
    &:last-child {
      margin-top: 22px;
    }
    .cols {
      margin-bottom: 15px;
      .col-box {
        font-size: 0.12rem;
        padding: 14px 17px;
        background-color: #f4f4f4;
        border-radius: 4px;
      }
      .text {
        color: #666;
      }
      .value {
        color: $blue;
        font-size: 0.19rem;
        margin-top: 14px;
        font-weight: 500;
      }
    }
  }
  .box {
    margin-top: 8px;
    .fans {
      display: flex;
      justify-content: space-between;
      align-items: center;
      p {
        color: #999;
        font-size: 0.12rem;
        span {
          margin-left: 5px;
        }
      }
      .trend {
        color: #2e2e2e;
        font-weight: bold;
        font-size: 0.15rem;
      }
      .day {
        display: flex;
        align-items: center;
      }
    }
  }
  .echarts {
    margin-top: -30px;
  }
}
</style>
